home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSSTR1.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-02
|
3KB
|
97 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bsstr.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains utility string functions. This modules uses floating
// point so it is in a separate module.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Description: Extract double value from a string.
// Parameters: psz String
// pg Pointer to double value storage. If null, don't
// save value. Contains 0.0 if return is FALSE.
// Returns: TRUE if string represented a valid long.
//----------------------------------------------------------------------------
BOOL FN_E strvaliddouble(PSZ psz, PDOUBLE pg)
{
PSZ pszSave = psz;
Assert(psz);
psz = strskipws(psz); // Skip leading whitespace
if (psz[0] == '+' || psz[0] == '-')
psz++; // Skip sign
while (isdigit(psz[0])) // Skip integral digits
psz++;
if (psz[0] == '.')
{
psz++;
while (isdigit(psz[0])) // Skip decimal digits
psz++;
}
if (psz[0] == 'd' || psz[0] == 'D' || psz[0] == 'e' || psz[0] == 'E')
{
psz++; // Skip exponent
if (psz[0] == '+' || psz[0] == '-')
psz++; // Skip sign
while (isdigit(psz[0])) // Skip digits
psz++;
}
psz = strskipws(psz); // Skip trailing whitespace
if (psz[0]) // Anything but a null means failure
{
if (pg)
pg[0] = 0.0;
return FALSE;
}
if (pg)
pg[0] = atof(pszSave);
return TRUE;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------